<?php
/**
 * Created by PhpStorm.
 * User: stupboy
 * Date: 2018/2/4
 * Time: 0:31
 */

namespace app\base\logic;
use app\base\service;

/**
 * 推送类
 * @package app\base\logic
 */
class Push
{
    /**
     * 推送司机自定义消息
     * @param $registration_id
     * @param $msg
     * @return bool|mixed
     */
    public function pushDriver($registration_id,$msg,$notice='',$expire=86400){
        //$push = new service\JPush();
        //$push->setKey('daaafb369d2efc08efc6a239','65a09a72b53f8c15a4ef7b66');
        // 增加个推
        $geTui = new service\GeTui();
        $geTui->setKey('3fiFqn10BI948QPAsQohk8','Wdn5ml9ywM6Ux9j3BPeVt2','3zoNaGDnYe8tgkzwmxxf17');
        $ret = $geTui->pushMessage($registration_id,$msg,$notice,$expire);
        trace($ret,'push');
        //return $push->pushMessage($registration_id,$msg,$notice);
    }

    /**
     * 推送乘客自定义消息
     * @param $registration_id
     * @param $msg
     * @return bool|mixed
     */
    public function pushPassenger($registration_id,$msg,$notice='',$expire=86400){
        // 极光
        //$push = new service\JPush();
        //$push->setKey('7787fd27355ebf708554e7dc','0b7dc5f2f0d3bafbd96b1ed7');
        // 增加个推
        $geTui = new service\GeTui();
        $geTui->setKey('8aODJK12lo75DIKUz5jpiA','3UbyEFHa2I7m0nmuJ3POP4','J9mYqqG0c9ArJtEnkANd55');
        $ret = $geTui->pushMessage($registration_id,$msg,$notice);
        //
        $geTui->setKey('PjFSzXi53b5Koh6RrEqYO9','t0GN3T2OyB753LiQCnBsnA','wbaNI1LsPr8uS86wnfzsc3');
        $geTui->pushMessage($registration_id,$msg,$notice,$expire);
        trace($ret,'push');
        //return $push->pushMessage($registration_id,$msg,$notice);
    }

    /**
     * 推送乘客通知
     * @param $registration_id
     * @param $msg
     * @return bool|mixed
     */
    public function pushPassengerNotice($registration_id,$msg){
        //$push = new service\JPush();
        //$push->setKey('7787fd27355ebf708554e7dc','0b7dc5f2f0d3bafbd96b1ed7');
        // 增加个推
        $geTui = new service\GeTui();
        $geTui->setKey('8aODJK12lo75DIKUz5jpiA','3UbyEFHa2I7m0nmuJ3POP4','J9mYqqG0c9ArJtEnkANd55');
        $ret = $geTui->pushNotice($registration_id,$msg);
        // 开发环境推送
        $geTui->setKey('PjFSzXi53b5Koh6RrEqYO9','t0GN3T2OyB753LiQCnBsnA','wbaNI1LsPr8uS86wnfzsc3');
        $geTui->pushNotice($registration_id,$msg);
        trace($ret,'push');
        //return $push->pushNotice($registration_id,$msg);
    }

    /**
     * 推送司机通知
     * @param $registration_id
     * @param $msg
     * @return bool|mixed
     */
    public function pushDriverNotice($registration_id,$msg){
//        $push = new service\JPush();
//        $push->setKey('daaafb369d2efc08efc6a239','65a09a72b53f8c15a4ef7b66');
        //个推
        $geTui = new service\GeTui();
        $geTui->setKey('3fiFqn10BI948QPAsQohk8','Wdn5ml9ywM6Ux9j3BPeVt2','3zoNaGDnYe8tgkzwmxxf17');
        $ret = $geTui->pushNotice($registration_id,$msg);
        trace($ret,'push');
//        return $push->pushNotice($registration_id,$msg);
    }
}